﻿#region  文件信息

// ---------------------------------------------------------------------------------------
// <copyright file="WapYlResponseNotice.cs" company="">
// 作者：李帅伦
// </copyright>
// <summary>
// 类型简介：
// 类型详细：WapYlResponseNotice.cs
// 创建时间：2014-12-25 12:58
// 修改时间：2014-12-24 14:27
// </summary>
// ---------------------------------------------------------------------------------------
#endregion

namespace Payment.WapYinlian
{
    #region

    using System;

    #endregion

    /// <summary>
    ///     得到通知后 提交到银联参数
    /// </summary>
    public class WapYlResponseNotice
    {
    

        #region Constructors and Destructors

        /// <summary>
        /// Initializes a new instance of the <see cref="WapYlResponseNotice"/> class. 
        /// </summary>
        public WapYlResponseNotice()
        {
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="WapYlResponseNotice"/> class. 
        /// </summary>
        /// <param name="model">
        /// </param>
        /// <param name="wapYlConfig">
        /// </param>
        public WapYlResponseNotice(WapYlRequestNotice model)
        { 
            this.TransCode = "201202";
            this.MerOrderId = model.MerOrderId;
            this.TransType = model.TransType;
            this.MerId = model.MerId;
            this.MerTermId = model.MerTermId;
            this.TransId = model.TransId;
            this.MerPlatTime = DateTime.Now.ToString("yyyyMMddhhmmss");
            this.Reserve = string.Empty;
        }

        #endregion

        #region Public Properties

        /// <summary>
        /// Gets or sets the mer id.
        /// </summary>
        public string MerId { get; set; }

        /// <summary>
        /// Gets or sets the mer Service id.
        /// </summary>
        public string MerOrderId { get; set; }

        /// <summary>
        /// Gets or sets the mer Service state.
        /// </summary>
        public string MerOrderState { get; set; }

        /// <summary>
        /// Gets or sets the mer plat time.
        /// </summary>
        public string MerPlatTime { get; set; }

        /// <summary>
        /// Gets or sets the mer sign.
        /// </summary>
        public string MerSign { get; set; }

        /// <summary>
        /// Gets or sets the mer term id.
        /// </summary>
        public string MerTermId { get; set; }

        /// <summary>
        /// Gets or sets the reserve.
        /// </summary>
        public string Reserve { get; set; }

        /// <summary>
        /// Gets or sets the trans code.
        /// </summary>
        public string TransCode { get; set; }

        /// <summary>
        /// Gets or sets the trans id.
        /// </summary>
        public string TransId { get; set; }

        /// <summary>
        /// Gets or sets the trans type.
        /// </summary>
        public string TransType { get; set; }

        #endregion

        #region Public Methods and Operators

        /// <summary>
        /// 进行验签
        /// </summary>
        /// <returns>
        /// The <see cref="string"/>.
        /// </returns>
        public string SetMerSign(WapYlConfig wapYlConfig)
        {
            var str = this.MerOrderId + this.TransType + this.MerId + this.MerTermId + this.TransId + this.MerPlatTime
                      + this.MerOrderState + this.Reserve;

            var rsaSign = RsaUtil.RsaSign(str,  wapYlConfig.Pvr);

            this.MerSign = rsaSign;
            return rsaSign;
        }

        #endregion
    }
}